<!--
 * @Author: your name
 * @Date: 2021-08-24 11:09:59
 * @LastEditTime: 2021-08-24 15:00:57
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \ewshop\src\components\content\tabControl\TabControl.vue
-->
<template>
  <div class="tab-control">
      <div class="tab-control-item" :class="{active:index == currentIndex}" v-for="(item,index) in titles" :key="index" @click="itemClick(index)">
          <span>{{item}}</span>
      </div>
      
  </div>
</template>

<script>
import {ref} from 'vue'
export default {
    name:"TabControl",
    props:{
        titles:{
            type:Array,
            default(){
                return [];
            }
        }
    },
    setup(props,context){
        let currentIndex = ref(0);
        const itemClick = (index) =>{
            currentIndex.value = index;
            context.emit('tabClick',index)
        }
        return{
            currentIndex,
            itemClick
        }
    }
}
</script>

<style scoped lang="scss">
.tab-control{
    display: flex;
    height: 40px;
    line-height: 40px;
    text-align: center;
    font-size: 14px;
    background-color: #fff;
    width: 100%;
    z-index: 10;
    position: sticky;
    top: 45px;
    .tab-control-item{
        flex:1;
        span{
            padding: 5px;
        }
    }
    .active{
        color: var(--color-tint);
        span{
            border-bottom: 3px solid var(--color-tint);
        }
    }

}
</style>